/*
 * @Author: Sunye
 * @Date: 2025-07-06 22:48:25
 * @LastEditors: Sunye
 * @LastEditTime: 2025-07-06 23:48:30
 * @Description:
 */
// eslint.config.js
import eslintPluginPrettier from 'eslint-plugin-prettier'
import eslintConfigPrettier from 'eslint-config-prettier'
import vueParser from 'vue-eslint-parser'
import tsParser from '@typescript-eslint/parser'
import globals from 'globals'

export default [
  // 基础 ESLint 配置
  {
    files: ['**/*.{js,ts,vue}'],
    languageOptions: {
      globals: {
        ...globals.browser,
        ...globals.node,
      },
      parser: vueParser,
      parserOptions: {
        parser: tsParser,
        ecmaVersion: 'latest',
        sourceType: 'module',
        extraFileExtensions: ['.vue'],
      },
    },
    plugins: {
      '@typescript-eslint': tsParser,
    },
    rules: {
      // 基础规则
      'no-console': 'warn',
    },
  },

  // Vue 3 规则
  {
    files: ['**/*.vue'],
    rules: {
      'vue/multi-word-component-names': 'off',
    },
  },

  // Prettier 集成 (必须放在最后)
  {
    files: ['**/*.{js,ts,vue}'],
    ...eslintConfigPrettier,
    plugins: {
      prettier: eslintPluginPrettier,
    },
    rules: {
      ...eslintPluginPrettier.configs.recommended.rules,
      'prettier/prettier': ['error', {}, { usePrettierrc: true }],
    },
  },
]
